找传奇、传世资源到传世资源站!

httpLib网络操作通用类采集例子,支持get/post/head/delete/...

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

本例子可以用来简化在 C# 应用中异步的访问 Web 服务的操作。同时包含文件上传和访问网页的方法。

Get data from web service

Request.Get("http://jthorne.co.uk/", result=>{ Console.Write(result);});

Download file from server

Request.Get("http://cachefly.cachefly.net/100mb.test", (headers, result) =>{ FileStream fs = new FileStream(@"C:\100mb.test", FileMode.OpenOrCreate); result.CopyTo(fs); fs.Close();});

Post data to web service

Request.Post("http://testing.local/post.php", new {name="james",username="Redslide"}, result=>{ Console.Write(result);});

Post data to web service and catch error

Request.Post("http://testing.local/post.php", new { name = "value"}, result=>{ Console.Write(result);}, e=>{ Console.Write(e.ToString());});

Upload file to server

Request.Upload("upload/attach/202206/img/605_44630.jpg", "image/jpeg", new FileStream(@"C:\photo.jpg",FileMode.Open))}, result=>{ Console.Write(result);});

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复